<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>破解保险箱</title>
</head>
<body>
  <script>
    function fn(n, k) {
      highest = Math.pow(10, n - 1);
      let ans = '';
      const seen = new Set();
      function dfs(node){
        for (let x = 0; x < k; ++x) {
          let nei = node * 10 + x;
          if (!seen.has(nei)) {
            seen.add(nei);
            dfs(nei % highest);
            ans += x
          }
        }
      };
      dfs(0);
      for (let i = 1; i < n; i++) {
        ans += '0'
      }
      return ans
    }
    console.log(fn(1, 2))
  </script>
</body>
</html>